# encoding: utf8
from django.db import models


class VendorProduct(models.Model):
    """
    **商家商品Model**

    +-----------------------------+-----------------+-------+-------+-------+
    |  字段名                     | 类型            | null  |  唯一 | 索引  |
    +=============================+=================+=======+=======+=======+
    | bar_code **[PK]**           | VARCHAR(50)     |   N   |   Y   |   Y   |
    +-----------------------------+-----------------+-------+-------+-------+
    | name                        | VARCHAR(128)    |   N   |   N   |   N   |
    +-----------------------------+-----------------+-------+-------+-------+
    | vendor_name                 | VARCHAR(128)    |   N   |   N   |   N   |
    +-----------------------------+-----------------+-------+-------+-------+
    | brand                       | VARCHAR(128)    | **Y** |   N   |   N   |
    +-----------------------------+-----------------+-------+-------+-------+
    | ware_id                     | VARCHAR(50)     | **Y** |   N   |   N   |
    +-----------------------------+-----------------+-------+-------+-------+
    | region                      | VARCHAR(128)    | **Y** |   N   |   N   |
    +-----------------------------+-----------------+-------+-------+-------+
    | packing                     | VARCHAR(128)    | **Y** |   N   |   N   |
    +-----------------------------+-----------------+-------+-------+-------+
    | weight                      | FLOAT           | **Y** |   N   |   N   |
    +-----------------------------+-----------------+-------+-------+-------+
    | tax_rate                    | FLOAT           | **Y** |   N   |   N   |
    +-----------------------------+-----------------+-------+-------+-------+
    | seo_info                    | LONGTEXT        | **Y** |   N   |   N   |
    +-----------------------------+-----------------+-------+-------+-------+
    | properties                  | LONGTEXT        | **Y** |   N   |   N   |
    +-----------------------------+-----------------+-------+-------+-------+
    """
    bar_code = models.CharField(max_length=50, primary_key=True, db_index=True)  # 国条码

    name = models.CharField(max_length=128, null=False)
    vendor_name = models.CharField(max_length=125)  # 商家名称
    brand = models.CharField(max_length=128)  # 品牌名称
    ware_id = models.CharField(max_length=50, null=False)  # 商品货号，对应商家原有的系统
    region = models.CharField(max_length=128, null=True)  # 产地
    packing = models.CharField(max_length=128, null=True)  # 包装方式
    weight = models.FloatField(null=True)  # 毛重
    tax_rate = models.FloatField(null=True)  # 税率
    seo_info = models.TextField(null=True)
    properties = models.TextField(null=True)  # 商品属性

    def __str__(self):
        return self.name
